import static org.junit.Assert.assertEquals;

import org.junit.Test;




/**
 * 
 */

/**
 * @author trefzger
 *
 */
public class OperandTypeTest {
	/**
	 * Module Name:
	 * Description:
	 * Calling Sequence
	 * 		Input Parameters
	 * 		Output Parameters
	 * Error Conditions Tested:
	 * Error Messages Generated:
	 * Original Author:
	 * Procedure Creation Date:
	 * Modification Log:
	 * 	 Who/When/Why
	 * Coding Standards Met: "Signed Code Leader(Jaron)"
	 * Testing Standards Met: "Signed Test Leader(Jamie)"
	 */
	@Test
	public void testValidateNone() {
		Boolean isValid = true;
		OperandType testop = new OperandType();
		
		String testOperand = null;
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.NONE, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "END";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.NONE, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.NONE, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = " ";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.NONE, false);
		assertEquals("isValid should be false.", false, isValid);
	} 
	@Test
	public void testValidateType1() {
		Boolean isValid = true;
		OperandType testop = new OperandType();
		
		String testOperand = "0";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE1, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "END";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE1, false);
		assertEquals("isValid should be false.", false, isValid);
		
		//TODO fix empty string case.
		testOperand = "";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE1, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = " ";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE1, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "4095";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE1, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "4096";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE1, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "2000";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE1, false);
		assertEquals("isValid should be true.", true, isValid);
		
	} 
	@Test
	public void testValidateType2() {
		Boolean isValid = true;
		OperandType testop = new OperandType();
		
		String testOperand = "0";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "END";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be true.", true, isValid);
		
		//TODO fix empty string case.
		testOperand = " ";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = " ";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "4095";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "4096";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "2000";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "TEST-label";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be true.", true, isValid);
		

		testOperand = "01020304050";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be false.", false, isValid);
		
		//TODO fix type 2 so that we throw an error if a string of numbers > 11 digits is given
		testOperand = "010203040506";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "a";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12345678910111213141516";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890165";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE2, false);
		assertEquals("isValid should be false.", false, isValid);
		
	} 
	@Test
	public void testValidateType3() {
		Boolean isValid = true;
		OperandType testop = new OperandType();
		
		String testOperand = "0";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "END";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be true.", true, isValid);
		
		//TODO fix empty string case.
		testOperand = "";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = " ";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "0";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "1";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "2";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "TEST-label";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be true.", true, isValid);
		

		testOperand = "01020304050";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be false.", false, isValid);
		
		//TODO fix type 2 so that we throw an error if a string of numbers > 11 digits is given
		testOperand = "010203040506";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "3";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "a";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12345678910111213141516";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890165";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE3, false);
		assertEquals("isValid should be false.", false, isValid);
	} 
	@Test
	public void testValidateType4() {
		Boolean isValid = true;
		OperandType testop = new OperandType();
		
		String testOperand = "0";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "END";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be true.", true, isValid);
		
//		//TODO fix empty string case.
		testOperand = "";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = " ";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "   ";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "0";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "1";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "23";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "TEST-label";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be true.", true, isValid);
		

		testOperand = "01020304050";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be false.", false, isValid);
		
		//TODO fix type 2 so that we throw an error if a string of numbers > 11 digits is given
		testOperand = "010203040506";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "24";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "a";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ12345678910111213141516";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890165";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.TYPE4, false);
		assertEquals("isValid should be false.", false, isValid);
	} 
	@Test
	public void testValidateOnOff() {
		Boolean isValid = true;
		OperandType testop = new OperandType();
		
		String testOperand = "On";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.ONOFF, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "oFF";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.ONOFF, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "END";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.ONOFF, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.ONOFF, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = " ";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.ONOFF, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "010203040506";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.ONOFF, false);
		assertEquals("isValid should be false.", false, isValid);
	} 
	@Test
	public void testValidateNum() {
		Boolean isValid = true;
		OperandType testop = new OperandType();
		
		String testOperand = "-16777216";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.NUM, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "16777215";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.NUM, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "END";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.NUM, false);
		assertEquals("isValid should be false.", false, isValid);
		
		//TODO fix the empty string case.
		testOperand = "";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.NUM, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = " ";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.NUM, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "16777216";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.NUM, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "-16777217";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.NUM, false);
		assertEquals("isValid should be false.", false, isValid);
	} 
	@Test
	public void testValidateBin() {
		Boolean isValid = true;
		OperandType testop = new OperandType();
		
		String testOperand = "11111111111111111111111";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.BIN, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "000000000000000000000001";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.BIN, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "END";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.BIN, false);
		assertEquals("isValid should be false.", false, isValid);
		
		//TODO fix the empty string case.
		testOperand = "";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.BIN, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = " ";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.BIN, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "01234567";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.BIN, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "11001455823";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.BIN, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "1111111111111111111111111";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.BIN, false);
		assertEquals("isValid should be false.", false, isValid);
	} 
	@Test
	public void testValidateStar() {
		Boolean isValid = true;
		OperandType testop = new OperandType();
		
		String testOperand = "*";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.STAR, false);
		assertEquals("isValid should be true.", true, isValid);
		
		testOperand = "END";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.STAR, false);
		assertEquals("isValid should be false.", false, isValid);
		
		//TODO fix the empty string case.
		testOperand = "";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.STAR, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = " ";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.STAR, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "01234567";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.STAR, false);
		assertEquals("isValid should be false.", false, isValid);
		
		testOperand = "11001455823";
		isValid = testop.validateOperandType(testOperand, OperandType.operandType.STAR, false);
		assertEquals("isValid should be false.", false, isValid);
		
	} 
}
